<template>
  <div class="container">
    <!-- 标题 -->
    <el-row class="header">
      <el-col :span="8">
        <h3>Stable Diffusion模型</h3>
        <el-select
          v-model="selectedModel"
          placeholder="选择模型"
          style="width: 200px"
        >
          <el-option label="GhostMix" value="GhostMix"></el-option>
          <!-- 添加其他模型选项 -->
        </el-select>
      </el-col>
      <el-col :span="4">
        <h3>外挂VAE模型</h3>
        <el-select
          v-model="selectedVAE"
          placeholder="选择VAE模型"
          style="width: 200px"
        >
          <el-option
            label="KIF8Anime2VAE_Ckpt"
            value="KIF8Anime2VAE_Ckpt"
          ></el-option>
          <!-- 添加其他VAE模型选项 -->
        </el-select>
      </el-col>
    </el-row>

    <!-- 内容区域 -->
    <el-row :gutter="20" class="content-area">
      <!-- 左侧拖放区域 -->
      <el-col :span="12">
        <div class="upload-box">
          <el-upload
            class="upload-container"
            drag
            action="https://jsonplaceholder.typicode.com/posts/"
            multiple
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload"
          >
            <div v-if="imageUrl">
              <img :src="imageUrl" class="avatar" />
            </div>
            <div v-else>
              <!-- <i class="el-icon-plus avatar-uploader-icon"></i> -->
              <i class="el-icon-upload"></i>
              <p>拖放图片至此处</p>
              <el-button type="primary">点击上传</el-button>
            </div>
          </el-upload>
        </div>
      </el-col>
      <!-- 右侧信息展示 -->
      <el-col :span="12" class="right-box">
        <!-- 按钮组 -->
        <div class="sellect-group">
          <div class="action-btn">
            <div class="logo-btn">
              <img src="@/assets/index/文生图.png" alt="" />
            </div>
            <div class="title-btn">
              <span>发放到 文生图</span>
            </div>
          </div>

          <div class="action-btn">
            <img src="@/assets/index/图生图.png" alt="" />
            <span>发送到 图生图</span>
          </div>
        </div>

        <div class="info-box">
          <div class="info-title">图片详细信息展示至此处</div>
          <div class="info-content">
            <!-- 这里可以添加具体的信息展示内容 -->
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selectedModel: "",
      imageUrl: "",
    };
  },
  methods: {
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === "image/jpeg";
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error("上传头像图片只能是 JPG 格式!");
      }
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 2MB!");
      }
      return isJPG && isLt2M;
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  max-width: 1700px;
  margin: 20px auto;
  padding: 20px;
  // background-color: #f0f2f5;
  border-radius: 8px;
  background: linear-gradient(#edf6ff 0%, #ffffff 19%);
  box-shadow: 0px 2px 8px 0px rgba(121, 141, 183, 0.2),
    inset 0px 0px 2px 0px #cde4ff;
  border-radius: 4px 4px 4px 4px;
  border: 1px solid #ffffff;
}
.header {
  margin-bottom: 40px;
}
.title {
  color: #333;
  font-size: 24px;
  margin-bottom: 20px;
}
.right-box {
  // background-color: #387aff;
  width: 800px;
  height: 520px;
  background: #ffffff;
  border-radius: 8px 8px 8px 8px;
  border: 1px solid #e0e4ec;
  // padding: 20px 10px;
  padding: 30px;
}
.model-select {
  width: 300px;
  margin-bottom: 20px;
}

.sellect-group {
  margin-bottom: 30px;
  display: flex;
  .action-btn {
    width: 373px;
    height: 138px;
    background: rgba(56, 122, 255, 0.06);
    border-radius: 8px 8px 8px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    span {
      font-family: PingFang SC, PingFang SC;
      font-weight: 500;
      font-size: 20px;
      color: #387aff;
      line-height: 23px;
      font-style: normal;
      text-transform: none;
    }
  }
  .action-btn:nth-child(2) {
    margin-left: 28px;
  }
}

.info-box {
  width: 774px;
  height: 294px;
  background: rgba(56, 122, 255, 0.06);
  border-radius: 8px 8px 8px 8px;
  padding: 20px;
}

.info-title {
  color: #606266;
  font-size: 16px;
  margin-bottom: 15px;
}

.upload-box {
  border: 2px dashed #8eace9;
  // border: 1px solid #387AFF;
  background: rgba(56, 122, 255, 0.06);
  border-radius: 6px;
  padding: 20px;
  text-align: center;
}

.upload-container {
  display: flex;
  justify-content: center;
  align-items: center;

  height: 476px;
}
::v-deep .el-upload-dragger {
  background-color: #fff !important;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-container p {
  color: #606266;
  font-size: 14px;
  margin: 10px 0;
}

/* 调整element默认样式 */
::v-deep .el-upload-dragger {
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
}
</style>
